<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"adoontheway.gitee.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="近期面试中遇到的一些技术方面的问题的总结">
<meta property="og:type" content="article">
<meta property="og:title" content="每天进步一点点015 - 近期面试的一些总结">
<meta property="og:url" content="https://adoontheway.gitee.io/2020/12/14/everydayprogress015/index.html">
<meta property="og:site_name" content="Ados">
<meta property="og:description" content="近期面试中遇到的一些技术方面的问题的总结">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-12-14T05:38:52.000Z">
<meta property="article:modified_time" content="2023-05-25T10:26:16.032Z">
<meta property="article:author" content="ado">
<meta property="article:tag" content="go">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://adoontheway.gitee.io/2020/12/14/everydayprogress015/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>每天进步一点点015 - 近期面试的一些总结 | Ados</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Ados</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">a fullstack game worker</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/adoontheway" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="external nofollow noopener noreferrer" target="_blank"><svg width="80" height="80" viewbox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://adoontheway.gitee.io/2020/12/14/everydayprogress015/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="ado">
      <meta itemprop="description" content="me, robot.">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ados">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          每天进步一点点015 - 近期面试的一些总结
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-12-14 13:38:52" itemprop="dateCreated datePublished" datetime="2020-12-14T13:38:52+08:00">2020-12-14</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-05-25 18:26:16" itemprop="dateModified" datetime="2023-05-25T18:26:16+08:00">2023-05-25</time>
              </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <div class="post-description">近期面试中遇到的一些技术方面的问题的总结</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="近期面试中遇到的一些问题的总结"><a href="#近期面试中遇到的一些问题的总结" class="headerlink" title="近期面试中遇到的一些问题的总结"></a>近期面试中遇到的一些问题的总结</h1><h2 id="规划"><a href="#规划" class="headerlink" title="规划"></a>规划</h2><p>近一年有1/3的时间中老家开荒种地，其他时间有用来学会和中年危机自处，虽然是失败了，还在调整中；有一部分时间用来思考和规划自己的未来，前期很盲目，后期在某音上看到某网红的3+1理论，大意是择业标准：趋势(主) + (爱好，能力，资源)的一个抉择，个人觉得很有道理。<br>自己选了 <strong>golang</strong> 作为后续的主要发展目标，完全摒弃了前端开发。当然，自己业余还是可以做一点的。<br>在网站上刷新状态，被动式找工作。<br>然后由于没有 <strong>golang</strong> 的实际操作经验，导致自己的面试的机会和面试的表现都很差劲。<br>所以今天决定静下心来学习和沉淀一些东西以认真的态度对待面试，以及面对自己的人生。<br>虽然前路迷茫，但是还得走一步是一步。</p>
<h2 id="问题汇总"><a href="#问题汇总" class="headerlink" title="问题汇总"></a>问题汇总</h2><h3 id="golang的垃圾回收"><a href="#golang的垃圾回收" class="headerlink" title="golang的垃圾回收"></a>golang的垃圾回收</h3><p><strong>golang</strong> 的垃圾回收机制和我之前所了解的 <strong>as</strong> 所使用的引用技术法有根本性的不同。<br><strong>golang</strong> 使用的是 <em>标记清除法</em>，即 <em>mark-sweeping</em>。<br>他主要是分为两步：</p>
<ul>
<li>标记：三色标记法，通过将所有对象区分为白，灰，黑三色，配合以写屏障 <em>write barrier</em></li>
<li>清理：清理所有的白色对象</li>
</ul>
<p>需要注意的是，标记清理期间需要暂停整个程序 <em>stw:stop the world</em></p>
<h3 id="变量逃逸"><a href="#变量逃逸" class="headerlink" title="变量逃逸"></a>变量逃逸</h3><p>一般代指局部变量本来应当分配到栈上的，但是这个局部变量在本作用域，即本函数外需要使用到，那么这个局部变量会被存储到堆上去。</p>
<h3 id="字符串拼接"><a href="#字符串拼接" class="headerlink" title="字符串拼接"></a>字符串拼接</h3><p>这个主要考察的是否你是否会直接使用 ‘+’ 来拼接字符串，其实跟 <strong>java</strong> 类似，<strong>java</strong> 有类似 <em>StringBuffer</em> 之类的东西来处理字符串拼接，<strong>golang</strong> 里面用的是 <em>string.Buffer</em> 来处理字符串拼接。<br>当然，我面试的时候回答用 ‘[]byte’ 来处理拼接也是可以的。但是，这里是需要指定长度的。不用 ‘+’ 进行操作也是这个运原理，一个<strong>string</strong> 其实代表的是一个 <strong>rune数组</strong>。</p>
<h3 id="内存分配的问题"><a href="#内存分配的问题" class="headerlink" title="内存分配的问题"></a>内存分配的问题</h3><p>之前被问到 <strong>slice</strong>的内存分配是什么样子的。我的回答是当前 <em>内存x2</em>。面试官接着问是否一直都是 <strong>x2</strong> 的申请呢？答案肯定不是。在 <strong>2048 byte</strong> 之前，内存都是 <strong>x2</strong> 的去申请，大于 <strong>2048 byte</strong> 的话每次申请 <strong>640 byte</strong>。</p>
<h3 id="处理channel超时"><a href="#处理channel超时" class="headerlink" title="处理channel超时"></a>处理channel超时</h3><p><em>goroutine</em> 超时可以通过 <em>Context.withtimeout</em> 和 <em>timer.after</em> 来处理。<br><em>goroutine</em> 是不能杀死的。</p>
<h3 id="for和range"><a href="#for和range" class="headerlink" title="for和range"></a>for和range</h3><p>不懂区别的最好用 <strong>for</strong>，因为无论在何种情况下<strong>for</strong>的性能永远是大于等于<strong>range</strong>的，<strong>range</strong>在循环复杂对象的时候性能会远小于 <strong>for</strong> ，当然，传入复杂对象指针除外。<br>想起面试过一个问题，<strong>map</strong> 的循环是引用还是值，其实，这个问题是值得商榷的，他循环是其实是值的复制。<br>另外，数组的基本值，不是引用类型。</p>
<h3 id="读写锁和互斥锁"><a href="#读写锁和互斥锁" class="headerlink" title="读写锁和互斥锁"></a>读写锁和互斥锁</h3><p>互斥锁就是 <strong>mutex.Lock</strong>， 读写锁就是 <strong>mutex.RWLock</strong> 。两者的区别是把读和写分开来，读写锁可以同时读，也就是只锁定写。效率在读多写少的情况下肯定是互斥锁强得多。</p>
<h3 id="常用缓存失效算法"><a href="#常用缓存失效算法" class="headerlink" title="常用缓存失效算法"></a>常用缓存失效算法</h3><ul>
<li>FIFO: first in first out</li>
<li>LFU: Least Frequenctly Used</li>
<li>LRU: Least Recently Used</li>
</ul>
<h2 id="分布式缓存相关"><a href="#分布式缓存相关" class="headerlink" title="分布式缓存相关"></a>分布式缓存相关</h2><h3 id="分布式缓存节点存值问题"><a href="#分布式缓存节点存值问题" class="headerlink" title="分布式缓存节点存值问题"></a>分布式缓存节点存值问题</h3><p>分布式缓存并不是每个节点上存的都一样，他是根据每个key进行hash操作然后确定这个缓存会存储到哪个节点上去。<br>这样节省了缓存空间，也提高了缓存效率。</p>
<h3 id="缓存雪崩"><a href="#缓存雪崩" class="headerlink" title="缓存雪崩"></a>缓存雪崩</h3><p>节点变化，例如 <strong>10</strong> 个变成了 <strong>9</strong> 个。那么h <em>hash</em> 取值就从 <code>hash(key)%10</code> 变成了 <code>hash(key)%9</code>。这样一来，几乎所有的缓存都失效了，节点接受到请求之后都需要重新去获取，就造成了缓存雪崩。</p>
<blockquote>
<p>缓存雪崩：缓存在同一时刻全部失效，造成瞬时DB请求量大、压力骤增，引起雪崩。常因为缓存服务器宕机，或缓存设置了相同的过期时间引起。</p>
</blockquote>
<p>解决缓存雪崩，需要用到一致性 <em>hash</em> 。</p>
<h3 id="一致性hash算法"><a href="#一致性hash算法" class="headerlink" title="一致性hash算法"></a>一致性hash算法</h3><p>一致性hash算法原理：</p>
<ul>
<li>一致性hash算法将key映射到2^32的空间中，这是一个首尾相连的环</li>
<li>计算节点的hash值，将他投放到环上，hash值通常以机器码，ip，编号等来计算</li>
<li>计算key的hash值，顺时针寻找到的第一个计算节点就是他存取的节点</li>
</ul>
<p>这样一来，新增/删除节点只需要重新定位这个节点附近的节点就可以了。  </p>
<h3 id="一致性hash可能会导致的数据倾斜问题"><a href="#一致性hash可能会导致的数据倾斜问题" class="headerlink" title="一致性hash可能会导致的数据倾斜问题"></a>一致性hash可能会导致的数据倾斜问题</h3><p>但是这样的话，由于机器hash分布不均匀，有可能导致数据倾斜。<br>为了解决这个问题，引入了虚拟节点，一个真实节点对应多个虚拟节点，例如：节点1包含节点1-1，节点1-2….即诶单1-n<br>代价是只需要维护一个map来存放虚拟节点的映射关系。  </p>
<h3 id="缓存击穿和缓存穿透"><a href="#缓存击穿和缓存穿透" class="headerlink" title="缓存击穿和缓存穿透"></a>缓存击穿和缓存穿透</h3><blockquote>
<p>缓存击穿：一个存在的key，在缓存过期的一刻，同时有大量的请求，这些请求都会击穿到 DB ，造成瞬时DB请求量大、压力骤增。</p>
</blockquote>
<blockquote>
<p>缓存穿透：查询一个不存在的数据，因为不存在则不会写到缓存中，所以每次都会去请求 DB，如果瞬间流量过大，穿透到 DB，导致宕机。</p>
</blockquote>
<p>这两个都是出现在并发请求过高的时候，优化的手段是同时收到的请求合并处理就可以了。</p>
<h3 id="Redis缓存淘汰策略"><a href="#Redis缓存淘汰策略" class="headerlink" title="Redis缓存淘汰策略"></a>Redis缓存淘汰策略</h3><p>缓存设置：</p>
<ul>
<li>在 redis 中，允许用户设置最大使用内存大小maxmemory，默认为0，没有指定最大缓存，如果有新的数据添加，超过最大内存，则会使redis崩溃，所以一定要设置。</li>
<li>redis 内存数据集大小上升到一定大小的时候，就会实行数据淘汰策略。</li>
<li>redis淘汰策略配置：maxmemory-policy voltile-lru，支持热配置  </li>
</ul>
<p>缓存淘汰策略：</p>
<ol>
<li>volatile-lru：从已设置过期时间的数据集（server.db[i].expires）中挑选最近最少使用的数据淘汰</li>
<li>volatile-ttl：从已设置过期时间的数据集（server.db[i].expires）中挑选将要过期的数据淘汰</li>
<li>volatile-random：从已设置过期时间的数据集（server.db[i].expires）中任意选择数据淘汰</li>
<li>allkeys-lru：从数据集（server.db[i].dict）中挑选最近最少使用的数据淘汰</li>
<li>allkeys-random：从数据集（server.db[i].dict）中任意选择数据淘汰</li>
<li>no-enviction（驱逐）：禁止驱逐数据</li>
</ol>
<h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><ul>
<li><a target="_blank" rel="external nofollow noopener noreferrer" href="https://geektutu.com/post/high-performance-go.html">Go 语言高性能编程</a></li>
<li><a target="_blank" rel="external nofollow noopener noreferrer" href="https://geektutu.com/post/geecache-day4.html">动手写分布式缓存 - GeeCache第四天 一致性哈希(hash)</a></li>
<li><a target="_blank" rel="external nofollow noopener noreferrer" href="https://www.oschina.net/group/database#/detail/2302258">Redis内存模型原理</a></li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/go/" rel="tag"># go</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/12/07/flutternotes/" rel="prev" title="flutter开发笔记">
      <i class="fa fa-chevron-left"></i> flutter开发笔记
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/12/16/everydayprogress016/" rel="next" title="每天进步一点点016 - sync.Map">
      每天进步一点点016 - sync.Map <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%BF%91%E6%9C%9F%E9%9D%A2%E8%AF%95%E4%B8%AD%E9%81%87%E5%88%B0%E7%9A%84%E4%B8%80%E4%BA%9B%E9%97%AE%E9%A2%98%E7%9A%84%E6%80%BB%E7%BB%93"><span class="nav-number">1.</span> <span class="nav-text">近期面试中遇到的一些问题的总结</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%A7%84%E5%88%92"><span class="nav-number">1.1.</span> <span class="nav-text">规划</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%97%AE%E9%A2%98%E6%B1%87%E6%80%BB"><span class="nav-number">1.2.</span> <span class="nav-text">问题汇总</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#golang%E7%9A%84%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6"><span class="nav-number">1.2.1.</span> <span class="nav-text">golang的垃圾回收</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%98%E9%87%8F%E9%80%83%E9%80%B8"><span class="nav-number">1.2.2.</span> <span class="nav-text">变量逃逸</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%8B%BC%E6%8E%A5"><span class="nav-number">1.2.3.</span> <span class="nav-text">字符串拼接</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%86%85%E5%AD%98%E5%88%86%E9%85%8D%E7%9A%84%E9%97%AE%E9%A2%98"><span class="nav-number">1.2.4.</span> <span class="nav-text">内存分配的问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%84%E7%90%86channel%E8%B6%85%E6%97%B6"><span class="nav-number">1.2.5.</span> <span class="nav-text">处理channel超时</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#for%E5%92%8Crange"><span class="nav-number">1.2.6.</span> <span class="nav-text">for和range</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%AF%BB%E5%86%99%E9%94%81%E5%92%8C%E4%BA%92%E6%96%A5%E9%94%81"><span class="nav-number">1.2.7.</span> <span class="nav-text">读写锁和互斥锁</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E7%BC%93%E5%AD%98%E5%A4%B1%E6%95%88%E7%AE%97%E6%B3%95"><span class="nav-number">1.2.8.</span> <span class="nav-text">常用缓存失效算法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%86%E5%B8%83%E5%BC%8F%E7%BC%93%E5%AD%98%E7%9B%B8%E5%85%B3"><span class="nav-number">1.3.</span> <span class="nav-text">分布式缓存相关</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%86%E5%B8%83%E5%BC%8F%E7%BC%93%E5%AD%98%E8%8A%82%E7%82%B9%E5%AD%98%E5%80%BC%E9%97%AE%E9%A2%98"><span class="nav-number">1.3.1.</span> <span class="nav-text">分布式缓存节点存值问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%93%E5%AD%98%E9%9B%AA%E5%B4%A9"><span class="nav-number">1.3.2.</span> <span class="nav-text">缓存雪崩</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%80%E8%87%B4%E6%80%A7hash%E7%AE%97%E6%B3%95"><span class="nav-number">1.3.3.</span> <span class="nav-text">一致性hash算法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%80%E8%87%B4%E6%80%A7hash%E5%8F%AF%E8%83%BD%E4%BC%9A%E5%AF%BC%E8%87%B4%E7%9A%84%E6%95%B0%E6%8D%AE%E5%80%BE%E6%96%9C%E9%97%AE%E9%A2%98"><span class="nav-number">1.3.4.</span> <span class="nav-text">一致性hash可能会导致的数据倾斜问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%93%E5%AD%98%E5%87%BB%E7%A9%BF%E5%92%8C%E7%BC%93%E5%AD%98%E7%A9%BF%E9%80%8F"><span class="nav-number">1.3.5.</span> <span class="nav-text">缓存击穿和缓存穿透</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Redis%E7%BC%93%E5%AD%98%E6%B7%98%E6%B1%B0%E7%AD%96%E7%95%A5"><span class="nav-number">1.3.6.</span> <span class="nav-text">Redis缓存淘汰策略</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8F%82%E8%80%83"><span class="nav-number">2.</span> <span class="nav-text">参考</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="ado" src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">ado</p>
  <div class="site-description" itemprop="description">me, robot.</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">94</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">60</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/adoontheway" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;adoontheway" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/adoontheway" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;adoontheway" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-github"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="http://cnblogs.com/adoontheway" title="Cnblogs → http:&#x2F;&#x2F;cnblogs.com&#x2F;adoontheway" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-cnblogs"></i>Cnblogs</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://legacy.gitbook.com/@adobeattheworld" title="Gitbook → https:&#x2F;&#x2F;legacy.gitbook.com&#x2F;@adobeattheworld" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-gitbook"></i>Gitbook</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">ado</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="external nofollow noopener noreferrer" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="external nofollow noopener noreferrer" target="_blank">NexT.Muse</a> 强力驱动
  </div>



        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//fastly.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  











<script>
document.querySelectorAll('.pdfobject-container').forEach(element => {
  let url = element.dataset.target;
  let pdfOpenParams = {
    navpanes : 0,
    toolbar  : 0,
    statusbar: 0,
    pagemode : 'thumbs',
    view     : 'FitH'
  };
  let pdfOpenFragment = '#' + Object.entries(pdfOpenParams).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&');
  let fullURL = `/lib/pdf/web/viewer.html?file=${encodeURIComponent(url)}${pdfOpenFragment}`;

  if (NexT.utils.supportsPDFs()) {
    element.innerHTML = `<embed class="pdfobject" src="${url + pdfOpenFragment}" type="application/pdf" style="height: ${element.dataset.height};">`;
  } else {
    element.innerHTML = `<iframe src="${fullURL}" style="height: ${element.dataset.height};" frameborder="0"></iframe>`;
  }
});
</script>


<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//unpkg.com/mermaid@8.14.0/dist/mermaid.min.js', () => {
    mermaid.initialize({
      theme    : '',
      logLevel : 3,
      flowchart: { curve     : 'linear' },
      gantt    : { axisFormat: '%m/%d/%Y' },
      sequence : { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>


  

  

</body>
</html>
